package com.zy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.entity.ZyMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

@Repository
@Mapper
public interface ZyMenuMapper extends BaseMapper<ZyMenu> {
    /**
     * 获取父菜单
     * @param username
     * @return
     */
    List<ZyMenu> getParentMenu(String username);

    /**
     * 根据父菜单id和用户权限获取菜单
     * @param pid
     * @param username
     * @return
     */
    List<ZyMenu> getChildrenMenuByParentMenuId(Integer pid, String username);

    //根据role_id获取菜单项
    @Select("select * from zy_menu where menu_id in(select menu_id from zy_role_menu_mapping where role_id = #{roleId})")
    Set<ZyMenu> getMenuByRoleId(Integer roleId);

}
